//
//  MoreCell.m
//  YSSmartHome
//
//  Created by yanghao on 16/9/18.
//  Copyright © 2016年 yahaong. All rights reserved.
//

#import "MoreCell.h"
#import "YHMarcros.h"
#import "UIView+Frame.h"

@interface MoreCell ()

@property(nonatomic, strong)UIButton *moreBtn;

@end
@implementation MoreCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    [self.contentView addSubview:self.moreBtn];
    [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.moreBtn.imageEdgeInsets = UIEdgeInsetsMake(0, self.moreBtn.titleLabel.intrinsicContentSize.width + 5, 0, -self.moreBtn.titleLabel.intrinsicContentSize.width - 5);
    self.moreBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -self.moreBtn.imageView.yh_width -5, 0, self.moreBtn.imageView.yh_width + 5);
//    for (UIView *subview in self.contentView.superview.subviews) {
//        if ([NSStringFromClass(subview.class) hasSuffix:@"SeparatorView"]) {
//            subview.hidden = NO;
//            CGRect frame = subview.frame;
//            frame.origin.x += self.separatorInset.left;
//            frame.size.width -= self.separatorInset.right;
//            subview.frame =frame;
//        }
//    }
}
- (void)setTitle:(NSString *)title
{
    _title = [title copy];
    [self.moreBtn setTitle:title forState:UIControlStateNormal];
}
- (UIButton *)moreBtn
{
    if (!_moreBtn) {
        _moreBtn = [[UIButton alloc]init];
        [_moreBtn setImage:[UIImage imageNamed:@"scene_more"] forState:UIControlStateNormal];
      //  [_moreBtn setTitle:@"更多启动条件" forState:UIControlStateNormal];
        [_moreBtn setTitleColor:RGBColor(102, 102, 102) forState:UIControlStateNormal];
        _moreBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        _moreBtn.userInteractionEnabled = NO;
    }
    return _moreBtn;
}
//- (void)addSubview:(UIView *)view
//{
//    if (![view isKindOfClass:[NSClassFromString(@"_UITableViewCellSeparatorView") class]] && view)
//        [super addSubview:view];
//}

@end
